<template>
  <div class="zheli-construct-spec-info">
    <el-row :gutter="20">
      <el-col :span="12"
              v-if="objRowRequest.is_indust_project =='1'">
        <el-form-item label="组织方式"
                      prop="org_type">
          <el-select v-model="objRowRequest.org_type"
                     class="sel-style"
                     clearable
                     placeholder="请选择组织方式">
            <el-option v-for="item in orgTypeCode"
                       :key="item.code_id"
                       :label="item.name"
                       :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结构类型"
                      prop="struct_type">
          <el-select v-model="objRowRequest.struct_type"
                     class="sel-style"
                     clearable
                     placeholder="请选择结构类型">
            <el-option v-for="item in constructTypeCode"
                       :key="item.code_id"
                       :label="item.name"
                       :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="装配式面积"
                      prop="assembly_area">
          <el-input v-model="objRowRequest.assembly_area"
                    placeholder="请输入装配式面积">
            <template slot="append">㎡</template>
          </el-input>
        </el-form-item>
        <el-form-item label="是否全装修"
                      prop="is_full_trim">
          <el-radio-group :disabled="status==='detail'"
                          v-model="objRowRequest.is_full_trim">
            <el-radio label="1">是</el-radio>
            <el-radio label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="全装修面积"
                      prop="full_trim_area">
          <el-input v-model="objRowRequest.full_trim_area"
                    placeholder="请输入全装修面积">
            <template slot="append">㎡</template>
          </el-input>
        </el-form-item>
        <!-- <el-form-item label="装配率">
          <el-input v-model="objRowRequest.assembly_rate"
                    placeholder="请输入装配率"></el-input>
        </el-form-item> -->
        <el-form-item label="是否智慧工地项目"
                      prop="is_wisdom">
          <el-radio-group :disabled="status==='detail'"
                          v-model="objRowRequest.is_wisdom">
            <el-radio label="1">是</el-radio>
            <el-radio label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="是否运用BIM技术"
                      prop="is_use_bim">
          <el-radio-group :disabled="status==='detail'"
                          v-model="objRowRequest.is_use_bim">
            <el-radio label="1">是</el-radio>
            <el-radio label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import { ProjectListApi } from '@/services/ProjectCenter'
import { standardCodeApi } from '@/services/StandardCode'
import { operaProjectMixin } from '@/mixins/operaProjectMixins'
export default {
  mixins: [operaProjectMixin],
  data () {
    return {
    }
  },
  methods: {
    // 初始化标准码
    async initCode (code, codeData, codeMap, codeLocal) {
      let local = window.localStorage.getItem(codeLocal)

      if (local) {
        this[codeData] = JSON.parse(local)
        this[codeMap] = []
        this[codeData].map((item) => {
          this[codeMap].push(item)
          //this[codeMap]一开始undefined,找不到item.value,会报错
          // this[codeMap][item.value] = item
        })
      } else {
        await this.getStandardCode(code, codeData, codeMap, codeLocal)
      }
    },
    // 获取标准码
    getStandardCode (code, codeData, codeMap, codeLocal) {
      return standardCodeApi.getStandardCodeData({
        data: {
          code_type: code
        }
      }).then(res => {
        if (res.code === 0 && res.data.list) {
          this[codeData] = res.data.list;
          this[codeMap] = []
          this[codeData].map((item) => {
            this[codeMap].push(item)
            // this[codeMap][item.value] = item
          })
          window.localStorage.setItem(codeLocal, JSON.stringify(res.data.list));
        }
      },
        err => {
          console.log(err);
        }
      );
    }
  },
  watch: {//监听

  },
  created () {
    // 组织方式标准码
    this.initCode('projectOrgType', 'orgTypeCode', 'projectOrgTypeMap', 'projectOrgTypeMap');
    // 结构类型标准码
    this.initCode('construct_type', 'constructTypeCode', 'constructTypeMap', 'constructTypeMap');
  }
}
</script>

<style lang="scss" scoped>
.zheli-construct-spec-info {
  padding: 20px 0px;
  .sel-style {
    width: 100% !important;
  }
}
</style>
